Note: this functionality is considered to be deprecated. Use Modularity instead.
Every composite control consists of two projects:
The component ActiveX project containing the VBVoice form and a class module.
A UserControl project containing any required property pages for the control.
Components are built as Visual Basic ActiveX DLL's or ActiveX EXE's.
The class module in this project acts as a link between the SubStart control and the VBVoice form. The project must reference the VBVSubBaseLib library and must implement the VBVSubBaseLib.Sub interface.
Much of the code in this class is boiler-plate code that can be copied from the sample provided. The remainder deals with managing the properties and characteristics exposed by the control.
The VBVoice form in this project is similar to any other VBVoice form, except that a SubBegin control is used instead of a LineGroup control and SubEnd controls are used instead of Onhook controls.
To add a custom icon to the SubStart control, you must first add an icon resource to the project. The icon is contained in a resource file and must have an id of 3000.
Runtime properties of the controls contained within the composite cannot be set directly. However, these properties can be set using the support provided in the host SubStart control, in conjunction with code in the class module.
The ChannelData property in the SubStart control is used to store the properties and the values required in the Enter event of the SubStart control. These values are passed to the composite after the event code has completed and the SubStart control transfers the call to the composite. A function in the class module of the composite receives the data and passes it to the controls on the form as required.
The Composite project should reference VBVSubBase.dll, which provides the interface used by the SubStart control to communicate with the composite.
A class module within the component defines:
The property pages to be shown as part of the SubStart control properties.
Any greetings which are exposed by the component and which can be modified from the calling application.
A class module must provide the interface between the component and the SubStart control. This module implements the interface VBVSubBaseLib.Sub - a sample class is provided.
You must modify the class by providing code for setting:
The names of the greetings
The greeting properties in the required controls
Other properties in controls and Visual Basic data variables as required
The class ID's of any required property pages
Several other functions are implemented by this class but the code can remain constant for all components.
Use sub_PropertyPages to tell the SubStart control which additional property pages to display. These property pages are defined in a separate ActiveX control (UserControl) project.
Private Property Get sub_PropertyPages(ByVal index As Long) As String
'this property tells the host control which property pages to display
'property pages must be defined in an activex control project
'currently we only have one property page
'retrieve the
guid for your property pages from oleview.exe by
' looking for
VBVSubPropPages.SubPage1
' (usercontrol project name).(propertypage
name)
Select Case index
Case 0:
sub_PropertyPages = "{3875b800-b18f-11d2-b3c0-00a0c91f10a0}"
Case 1:
sub_PropertyPages = "{3875b800-b18f-11d2-b3c0-00a0c91f10a0}"
End Select
End Property
See Creating Property Pages for Composite controls.
sub_SubDataValue is used by the property page to set new property values into the composite.
EXAMPLE: We expose only the maximum loop count property. The new value is loaded into the IMaxCount property of the Count control.
'used to set properties of control
Private Property Let sub_SubDataValue(ByVal name As String, ByVal RHS As String)
On Error Resume Next
If name = "count" Then
'we only use one property in this example
SubForm.count1.IMaxCount = Val(RHS)
End If
Exit Property
End Property
See Creating Property Pages for Composite controls.
Use the sub_SubDataValue function to return the value of any properties exposed by the composite.
EXAMPLE: We expose only the IMaxCount property.
Private Property Get sub_SubDataValue(ByVal name As String) As String
On Error Resume Next
If name = "count" Then
'we only use one property in this example
sub_SubDataValue = 0
End If
End Property
See Creating Property Pages for Composite controls.
Use the sub_GreetingNames function to provide the names of additional greetings provided by the composite. These greeting names will be displayed and modified in the Greetings property page of the SubStart control.
EXAMPLE: The control exposes two greetings for modification, Greet1 and Greet2. These two greetings are actually the EntryGreeting of the PlayGreeting control and the MusicGreeting of the Delay control.
Private Property Get sub_GreetingNames(ByVal index As Long) As String
Select Case index
Case 0:
sub_GreetingNames
= "greet1"
Case 1:
sub_GreetingNames
= "greet2"
End Select
End Property
Use sub_Greetings to retrieve the greeting objects that have been marked (by sub_GreetingNames) as external in the composite. Each named greeting in sub_GreetingNames must return a greeting object. This function is used by the Greetings property page of the SubStart control to get and set the content of the greetings.
EXAMPLE:
Private Property Get sub_Greetings(ByVal index As Long) As Object
Select Case index
Case 0:
Set sub_Greetings =
SubForm.PlayGreeting1.EntryGreeting
Case 1:
Set
sub_Greetings = SubForm.Delay1.MusicGreeting
End Select
End Property
The following functions are standard for all composite controls. Normally these functions require no changes, except for the names of the Form and the SubBegin control.
Class_Initialize is called when the component is first loaded. It causes the form containing the VBVoice controls to be loaded.
EXAMPLE:
Private Sub Class_Initialize()
'set the name of your form here if not SubForm
Load SubForm
Set mainform = SubForm
End Sub
See Class_Initialize.
Class_Terminate unloads the form when the component is unloaded.
EXAMPLE:
Private Sub Class_Terminate()
On Error Resume Next
Unload mainform
End Sub
See Class_Terminate.
Sub_CompletionCode allows the SubStart control to retrieve the reason for the end of the call. It should not be changed.
EXAMPLE:
Private Property Get Sub_CompletionCode(ByVal channel As Integer) As String
Sub_CompletionCode = SubForm.SubBegin1.CompletionCode(channel)
End Property
Sub_CompletionType allows the SubStart control to retrieve the exit node that the SubStart control uses at the end of the call. It should not normally be changed.
EXAMPLE:
Private Property Get Sub_CompletionType(ByVal channel As Integer) As Integer
Sub_CompletionType = SubForm.SubBegin1.CompletionType(channel)
End Property
Sub_StartChannel is used in Active EXE components to allow the SubStart control to start voice operations on the channel. It is called in the voice thread and does not return until voice processing in the component is completed. Do not set breakpoints in this function!
EXAMPLE:
Private Sub Sub_StartChannel(ByVal channel As Integer)
On Error Resume Next
SubForm.SubBegin1.StartCall channel
If
Err.Number <> 0 Then
Err.Raise
vbObjectError + Err.Number
End If
End Sub
The sub_StartControl is used in ActiveX DLL components to transfer the call to the SubBegin to start processing.
EXAMPLE:
Public Property Get sub_StartControl() As Long
On Error Resume Next
'return the control
from which to start sub
'scan through the controls looking for a
SubBegin control, and return it
Dim ctrl As Control
For
Each ctrl In mainform.Controls
If TypeName(ctrl)
= "SubBegin" Then
sub_StartControl
= ctrl.ControlThis
Exit
Property
End If
Next
End Property
The sub_SubEndControlName function scans the form to assemble a list of SubEnd controls. The list of control names is then returned one by one to the SubStart control, and allows SubStart to display the names of the controls in its output node list. Other names can be substituted if required.
EXAMPLE:
Private Property Get sub_SubEndControlName(ByVal index As Long) As
String
'return the control from which to
start sub
'scan thru the controls looking for a Subenter control,
and return it
On Error GoTo errsubend
If subends.Count = 0 Then
Dim ctrl As Control
For Each ctrl In SubForm.Controls
If
TypeName(ctrl) = "SubEnd" Then
subends.Add
ctrl.INodeName
End If
Next
End If
' if index is out of range, throw error
If index >
subends.Count Then
Exit Property 'just return
nothing
End If
sub_SubEndControlName = subends.Item(index)
Exit Property
errsubend:
Exit Property
End Property
In an ActiveX EXE composite, use the sub_StartSystem function to start the system before any calls are passed to it.
EXAMPLE:
Private Sub sub_StartSystem()
'required by activeX EXE's only
On Error Resume Next
mainform.VBVFrame1.StartSystem 0
End Sub
This method is called to load change runtime properties immediately before a call is passed to the composite. It is called once for each property set using the channelData method in the SubStart control.
EXAMPLE:
In this method your code can then load the data into the controls on the form.
Sub_SetChannelValue
Private Sub Sub_SetChannelValue(ByVal name As
String, ByVal value As String, ByVal channel As Long)
On Error Resume Next
If name = "callid" Then
mainform.SubBegin1.SetLoggingCallID
channel, Val(value)
End If
mainform.Delay1.DelayTime(channel)
= 10
If Err.Number <> 0 Then
Err.Raise
vbObjectError + Err.Number
End If
End Sub